﻿<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<link rel="stylesheet" type="text/css" media="screen" href="css/jquery-ui-1.8.1.custom.css" />
<link rel="stylesheet" type="text/css" media="screen" href="css/ui.jqgrid.css" />
<script src="js/jquery-1.5.2.min.js" type="text/javascript"></script>
<script src="js/i18n/grid.locale-cn.js" type="text/javascript"></script>
<script src="js/json2.js" type="text/javascript"></script>
<script src="js/xing.js" type="text/javascript"></script>
<script type="text/javascript">
	$.jgrid.no_legacy_api = true;
	$.jgrid.useJSON = true;
</script>
<script src="js/jquery.jqGrid.min.js" type="text/javascript"></script>
<script type="text/javascript">
var uprof;

function setGrid() {
	jQuery("#list1").jqGrid({ 
			url:'main?action=16',
			datatype: "json",
			hidegrid: "false",
			colNames:['用户ID','姓名','密码','资质'], 
			colModel:[
					{name:'uid', width:150,sortable:false, align:'right',editable:true,editoptions:{size:8,maxlength:6},editrules:{required:true}}, 
					{name:'uname', width:240, sortable:false, align:'right',editable:true,editoptions:{size:8,maxlength:8},editrules:{required:true}}, 
					{name:'upass', width:180, sortable:false, align:'right',editable: true, edittype:"password",editoptions:{size:6,maxlength:6},editrules:{edithidden:true,required:true},hidden:true},
					{name:'prof', width:240, sortable:false, align:'right',editable:true,editoptions:{size:8,maxlength:1},editrules:{number:true,required:true}}
			], 
			viewrecords: true,
			rowNum:200,
			pager: '#gridpager1',
			editurl:'main?action=16',
			caption:"服务商坐席人员管理",
			height: 400,
			gridComplete: function() {
				uprof = jQuery("#list1").jqGrid('getGridParam', 'userData')["uprof"];
				//setGridButton();
			}
  })
}; 
	
	$(document).ready(function(){
		setGrid();
		
		jQuery("#list1").jqGrid('navGrid','#gridpager1',{edit:false,add:false,del:false,refresh:false,search:false})
		.jqGrid('navButtonAdd','#gridpager1',{
   		caption:"添加", 
   		buttonicon:"ui-icon-plus", 
   		onClickButton: function(){
				jQuery("#list1").jqGrid('editGridRow','new',{
					addCaption:"添加一个坐席人员",
					bSubmit:"保存",bCancel:"取消",modal: true, 
					closeAfterAdd:true, 
					reloadAfterSubmit:true,
					afterSubmit : function(r, postdata) {
			  					var data = eval('(' + r.responseText + ')');
			  					switch (data.code) {
			  						case 0: return [true, data.message];
			  						case 30000: return [false, "添加失败，用户ID不能重复！"];
			  					}
			  	}
			  }); 
			}
		})
		.jqGrid('navButtonAdd','#gridpager1',{
   		caption:"更改", 
   		buttonicon:"ui-icon-wrench", 
   		onClickButton: function(){
				var gr = jQuery("#list1").jqGrid('getGridParam','selrow');
				if( gr != null )
			  	jQuery("#list1").jqGrid('editGridRow',gr,{
			  		editCaption:"更改坐席人员信息",
			  		bSubmit:"保存",bCancel:"取消",modal: true,
			  		closeAfterEdit:true,
			  		viewPagerButtons:false,
			  		reloadAfterSubmit:true,
			  		afterSubmit : function(r, postdata) {
				  					var data = eval('(' + r.responseText + ')');
				  					if (data.code != 0)
				  						return [false, data.message];
				  					else
				  						return [true, data.message];
				  	}
				  });
				else
					showTips("请选择要更改的坐席人员");
			}
		})
		.jqGrid('navButtonAdd','#gridpager1',{
   		caption:"删除", 
   		buttonicon:"ui-icon-close", 
   		onClickButton: function(){
				var gr = jQuery("#list1").jqGrid('getGridParam','selrow');
				if( gr != null )
			  	jQuery("#list1").jqGrid('delGridRow', gr, {
			  		caption:"确定要删除这个坐席人员吗?", 
			  		msg:"确定要删除这个坐席人员？",
			  		bSubmit:"删除",bCancel:"取消",modal: true,
			  		closeAfterEdit:true, 
			  		reloadAfterSubmit:true,
			  		afterSubmit : function(r, postdata) {
				  					var data = eval('(' + r.responseText + ')');
				  					if (data.code != 0)
				  						return [false, data.message];
				  					else
				  						return [true, data.message];
				  	}
				  });
				else
					showTips("请选择要删除的坐席人员");
			}
		});
	});
</script>

<body style="background-color:#d9f1cc;">
				<div id="RightPane">
					<div class="innertube">
					<table id="list1"></table>
					<div id="gridpager1"></div>
					</div>
				</div>
</body>
